﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Data.Services.Client;
using System.Reflection;
using System.Windows.Forms;

namespace ODataSource
{
    internal class ContextPropertyEditor: StringConverter
    {
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }

        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            var list = new List<string>();           
            var assemblies = AppDomain.CurrentDomain.GetAssemblies();

            try
            {
                foreach (var asm in assemblies)
                        list.AddRange(from element in asm.GetTypes()
                                      where element.IsSubclassOf(typeof(DataServiceContext))
                                      select element.FullName);
            }
            catch
            {
                ;
            }

            list.Sort();

            return new StandardValuesCollection(list);                    
        }
    }
}
